module.exports = app => {
  const mongoose = app.mongoose;
  const RoomSchema = new mongoose.Schema({
    serialNumber: { //房间号
      type: Number,
      index: true,
      unique: true
    },
    player: {
      type: [String],
      default: []
    },
    owner: String,
    insert_time: Date,
    gameInfo: {
      round: {
        type: Number,
        default: 0
      }, //目前回合数
      lastPocker: {
        type: [String],
        default: []
      }, //剩余的牌
      needPay: {
        type: Number,
        default: 0
      }, //此时退出游戏需要支付的分数
      callPay: {
        type: Number,
        default: 0
      }, //此时叫到的分数，即下一次叫分时的needPay
      playerInfo: [{ //玩家状态
        name: {
          type: String,
          required: true
        },
        id: {
          type: String,
          required: true
        },
        headImage: String,
        score: {
          type: Number
        },
        isReady: {
          type: Boolean,
          default: false
        },
        pocker: {
          type: [{
            display: Boolean,
            value: String
          }],
          default: []
        }
      }]
    }
  });

  return mongoose.model('Room', RoomSchema);
}